Skip to content

Doc: Update references and examples of old, unsupported OSes and uarches #92791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 9, 2022

Conversation

CAM-Gerlach
Copy link
Member

As a followup to PR #92529 resolving issue #76773 , I also noticed a few other references to legacy OSes that are no longer supported by Python (or their own developers) per PEP 11 (PEP-11) that I elided or updated. More impactfully, I rewrote several descriptions and examples (e.g. in socket and struct) that were very out of date with modern 64-bit architectures. To keep this narrowly scoped and backportable, I avoided changes that were too broad or could potentially affect references that were still of some modern value.

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels May 13, 2022
@CAM-Gerlach CAM-Gerlach changed the title Doc: Update references and examples with old, unsupported OSes and uarches Doc: Update references and examples of old, unsupported OSes and uarches May 13, 2022
would be two bytes, while binary is four. Of course, this doesn't fit well with
fixed-length messages. Decisions, decisions.
amount of the time, all those integers have the value 0, or maybe 1.
The string ``"0"`` would be two bytes, while a full 64-bit word would be 8.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not fit with functions ntohl, htonl, ntohs, htons, described in previous paragraph, which only work with 16 and 32 bit integers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'm not sure it has to, since those two paragraphs are describing separate topics, and the respective integer widths are each appropriate to the point being made—the standard library functions are nominally for smaller 16 and 32-bit integers, while modern machines and Python's own native integer type are 64-bit, where encoding small integers as ASCII/UTF-8 has the greatest potential size advantage over binary, while also avoiding the need to potentially convert endianness, particularly so when the aforementioned functions are not available for 64-bit ints (though perhaps one could be added).

Is there something specific you'd like me to add/clarify here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is obvious to me that this paragraph refers to the previous one. It's mention of "all those longs" is a reference to "long" in ntohl and htonl which is always 32-bit.

Also, on most modern 64-bit platforms the standard integer type int in C is 32-bit. On Windows even long is 32-bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is obvious to me that this paragraph refers to the previous one. It's mention of "all those longs" is a reference to "long" in ntohl and htonl which is always 32-bit.

Okay, thanks for providing something specific. I replaced that wording with "most integers", as well as clarified the terminology in the following sentence as well. If there's something else specific you would like me to change, let me know.

Also, on most modern 64-bit platforms the standard integer type int in C is 32-bit. On Windows even long is 32-bit.

Yes, if by "standard" you mean the C type that has the name int. Of course, this is less relevant for Python users, given Python only has one native integer type, nominally 64 bits, and this how-to does not focus on the C API. In any case, the use of a native 64-bit integer is appropriate to making the point of the section, that with wider binary types, representing small numbers as text may actually be more efficient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3 does not have a native fixed-width integer type. There was one in Python 2, but it was 32-bit on Windows.

Well, I think it is not important.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3 does not have a native fixed-width integer type. There was one in Python 2, but it was 32-bit on Windows.

Sorry, I should have used clearer terminology—what I meant to imply was "native" to the language vs. third party (e.g. Numpy dtypes), but in this context "native" more conventionally means platform-native, as you say above. I also somewhat inaccurately simplified Python's int type to be a fixed-width 64-bit integer, when that's not truly the case.

@@ -53,7 +53,7 @@ Cross Platform

.. function:: machine()

Returns the machine type, e.g. ``'i386'``. An empty string is returned if the
Returns the machine type, e.g. ``'AMD64'``. An empty string is returned if the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it what returned on the AMD processors? On my computer it is 'x86_64'.

Update also the docstring of platform.machine().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original 'proper' name of what is also called the "x86-64" architecture is AMD64, as it was created by AMD and later adopted by Intel when Intel's IA-64 (Itanium) architecture failed in the market. What is returned depends (AFAIK) on the OS, not the CPU; Windows and many (most?) Linux distros call it AMD64 internally, while Apple and some others call it x86-64. Running a freshly built from main Python, as well as 3.9 and 3.10 release builds, platform.machine() returns AMD64 on my Windows system with a stock Intel i7-3730.

Update also the docstring of platform.machine().

I can, but as this PR currently only modifies the docs, I'd rather do that separately; there are other places in the codebase that should be updated too, for consistency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstrings are a part of the docs. If we do not update them together with the rst files, they are left desynchronized.

Copy link
Member Author

@CAM-Gerlach CAM-Gerlach May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only affects the choice of one specific example, both of which are equally accurate and valid, and which will be synchronized if and when I do a similar pass through the codebase itself. Several of the other platform functions, e.g. system(), have differing examples on each. And given the rest of this PR scrupulously avoids touching the code, adding this one trivial change has non-trivial cost, of triggering and requiring a whole suite of extra builds/CIs, and increasing risk for backporting.

Given the change was minor and not strictly required in the first place, and I almost didn't make it, if this is going to be a big issue I'll just drop this change instead, since its not at all worth the cost.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way the docstrings and the documentation should be consistent.

@serhiy-storchaka serhiy-storchaka removed the needs backport to 3.9 only security fixes label May 20, 2022
would be two bytes, while binary is four. Of course, this doesn't fit well with
fixed-length messages. Decisions, decisions.
amount of the time, all those integers have the value 0, or maybe 1.
The string ``"0"`` would be two bytes, while a full 64-bit word would be 8.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python 3 does not have a native fixed-width integer type. There was one in Python 2, but it was 32-bit on Windows.

Well, I think it is not important.

@@ -53,7 +53,7 @@ Cross Platform

.. function:: machine()

Returns the machine type, e.g. ``'i386'``. An empty string is returned if the
Returns the machine type, e.g. ``'AMD64'``. An empty string is returned if the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way the docstrings and the documentation should be consistent.

@ambv ambv merged commit a5ba0f4 into python:main Jun 9, 2022
@miss-islington
Copy link
Contributor

Thanks @CAM-Gerlach for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 9, 2022
@bedevere-bot
Copy link

GH-93638 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jun 9, 2022
@bedevere-bot
Copy link

GH-93639 is a backport of this pull request to the 3.10 branch.

@CAM-Gerlach
Copy link
Member Author

Thanks @serhiy-storchaka for the review and @ambv for the merge, and sorry for the very long time being unresponsive—I crashed hard after Pycon and had to take a break to recover, catch up on my actual work/research, and assist a family member in a difficult time.

Also, I apologize for the unnecessarily drawn out responses to the review comments; I should have make them more concise and focused on what I'd done to address them rather than getting too deep into the minutia. I'll work on that in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants